package cate.game.activity.mtowerchallenge.msg;

import cate.common.util.GameResult;
import cate.game.GameBody;
import cate.game.activity.mtowerchallenge.MTowerChallengeActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBMTower;
import easy.java.dev.note.NoteField;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@ClientMsg(title = "魔塔挑战关卡挑战 の 请求")
public class MTowerChallengeReq implements MsgInput {
    @NoteField("功能id")
    public int funcId;
    @NoteField(value = "层数id")
    public int level;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        MTowerChallengeActivity single = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (single == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        GameResult<MTowerChallengeActivity> result = single.challenge(level);
        if (!result.ok()) {
            game.notice.message(cc.getRole(), result.message);
        }
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBMTower.CHALLENGE_REQ;
    }
}
